package com.cxl.demo.service;

import com.cxl.demo.mapper.LogisticsMapper;
import com.cxl.demo.vo.Logistics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class LogisticsServiceImpl implements LogisticsService{


    @Autowired
    LogisticsMapper logisticsMapper;

    @Override
    public Integer Add(Logistics logistics) {


        List<Logistics> list=logisticsMapper.getHistoryList(logistics.getBuyHistoryId());
        Boolean flag=true;
        for(Logistics item:list){
            if(item.getContent().equals(logistics.getContent())){
                flag=false;
            }
        }
        if(flag){


            logisticsMapper.Add(logistics);
            return 1;
        }else{
            return 0;
        }


    }

    @Override
    public List<String> getLogistics() {
        List<String> list=new ArrayList<>();
        list.add("待发货");
        list.add("已揽收");
        list.add("已发货");
        list.add("待取货");
        list.add("已取货");
        return list;
    }

    @Override
    public List<Logistics> getHistoryList(Integer buyHistoryId) {



        return logisticsMapper.getHistoryList(buyHistoryId);
    }
}
